path <-
"/Users/robert/ab-1279/Alameda/Parcels-shp/"
alameda_county_parcel_data <-
read_sf(path)
Constants
QUARTER_ACRE <-
10890 # SQUARE FEET
HALF_ACRE <-
21780 # SQUARE FEET
NONZERO_PARCEL_SIZE_COUNT_UNIQUE_APN_SORT <-
97474
access_token <-
"pk.eyJ1Ijoicm9iZXJ0c3ByYWdnIiwiYSI6ImNqd2NtNjh0YzBiNzMzenBsNDl3cXQ1em8ifQ.1d2QhIjr8R8ZUlzjwcYx9w"
style_oakland_map <-
"mapbox://styles/robertspragg/ckce9o0fi09vb1ipdrpo41iq8"
parcels_no_geometry <-
alameda_county_parcel_data %>%
st_drop_geometry()
parcels_geom_only <-
alameda_county_parcel_data %>%
select(geometry, APN_SORT, OBJECTID, LotSize) %>%
st_transform(crs = 4326)
oakland_parcels <-
parcels_no_geometry %>%
filter(SitusCity == "OAKLAND")
Number of Parcels greater than Quarter Acre (10890 square feet)
oakland_parcels %>%
group_by(APN_SORT) %>%
slice(1) %>% # 98,294
filter(LotSize > 0) %>% # 97,474
filter(LotSize > QUARTER_ACRE)
## # A tibble: 10,723 x 65
## # Groups: APN_SORT [10,723]
## OBJECTID APN APN_SORT BOOK PAGE PARCEL SUB_PARCEL CLCA_CATEG
## <int> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 2546 1-11… 001 011… 1 111 5 2 <NA>
## 2 2547 1-11… 001 011… 1 111 5 3 <NA>
## 3 2320 1-11… 001 011… 1 113 1 1 <NA>
## 4 2319 1-11… 001 011… 1 113 1 2 <NA>
## 5 2316 1-11… 001 011… 1 113 2 2 <NA>
## 6 2317 1-11… 001 011… 1 113 3 <NA> <NA>
## 7 2299 1-11… 001 011… 1 115 13 12 <NA>
## 8 2296 1-11… 001 011… 1 115 37 <NA> <NA>
## 9 2283 1-11… 001 011… 1 117 2 1 <NA>
## 10 2282 1-11… 001 011… 1 117 3 <NA> <NA>
## # … with 10,713 more rows, and 57 more variables: COMMENTS <chr>,
## # DATE_CREAT <chr>, DATE_UPDAT <chr>, EDITOR <chr>, FID_PARCEL <int>,
## # CENTROID_X <dbl>, CENTROID_Y <dbl>, SortParcel <chr>,
## # PrintParce <chr>, TRAPrimary <chr>, TRASeconda <chr>,
## # SitusStree <chr>, SitusStr_1 <chr>, SitusUnit <chr>, SitusCity <chr>,
## # SitusZip <chr>, SitusZip_4 <chr>, Land <dbl>, Imps <dbl>,
## # CLCALand <dbl>, CLCAImps <dbl>, HOEX <dbl>, OTEX <dbl>,
## # TotalNetVa <dbl>, LatestDocu <chr>, LatestDo_1 <chr>,
## # LatestDo_2 <date>, MailingAdd <chr>, MailingA_1 <chr>,
## # MailingA_2 <chr>, MailingA_3 <chr>, MailingA_4 <chr>, UseCode <chr>,
## # EconUnit <chr>, Units <int>, Class <chr>, EffectiveY <int>,
## # BuildingAr <int>, LotSize <int>, Buildings <int>, Stories <int>,
## # Rooms <int>, Beds <int>, Acre <chr>, LandType <chr>, Conformity <chr>,
## # Additions <int>, YearBuilt <int>, Baths <dbl>, Condo <chr>,
## # Elevator <chr>, Pool <chr>, EconomicUn <int>, SitusAddre <chr>,
## # MailingA_5 <chr>, SHAPE_Leng <dbl>, SHAPE_Area <dbl>
oakland_parcels_half_acre <-
oakland_parcels %>%
group_by(APN_SORT) %>%
slice(1) %>% # 98,294
filter(LotSize > 0) %>% # 97,474
filter(LotSize > HALF_ACRE) %>%
select(APN_SORT, LotSize) %>%
inner_join(parcels_geom_only)
## Joining, by = c("APN_SORT", "LotSize")
oakland_parcels_quarter_acre <-
oakland_parcels %>%
group_by(APN_SORT) %>%
slice(1) %>% # 98,294
filter(LotSize > 0) %>% # 97,474
filter(LotSize > QUARTER_ACRE) %>%
select(APN_SORT, LotSize) %>%
inner_join(parcels_geom_only)
## Joining, by = c("APN_SORT", "LotSize")
parcel_list_half_acre <-
oakland_parcels_half_acre %>% select(APN_SORT) %>% pull
parcel_list_quarter_acre <-
oakland_parcels_quarter_acre %>% select(APN_SORT) %>% pull
leaflet(parcels_geom_only %>% filter(APN_SORT %in% parcel_list_half_acre)) %>%
addMapboxGL(
accessToken = access_token,
style = style_oakland_map
) %>%
addPolygons(color = "#444444", weight = 1, smoothFactor = 0.5,
opacity = 1.0, fillOpacity = 0.5,
fillColor = ~colorQuantile("YlOrRd", LotSize)(LotSize),
highlightOptions = highlightOptions(color = "white", weight = 2,
bringToFront = TRUE))